

---@class unit "单位"
local unit           = {}
setmetatable(unit, unit)
ac.unit = unit

unit.dbgcount = 0

local mt = {}
unit.__index = mt

--设置目标坐标
function mt:set_point(point)
    local owner = self.owner
    self.point = point
    owner:sendWar3('设置单位位置',self.handle,point)
end

function unit.create(owner, name, where)
    local x = where and where.x or 0
    local y = where and where.y or 0

    local u = setmetatable({}, unit)
    u.point = ac.point(x,y)
    u.owner = owner

    unit.dbgcount = unit.dbgcount + 1
    
    owner:sendWar3('创建单位',self.handle,point)
end


-- 给玩家创建单位
function ac.player.__index:create_unit(name, where, facing)
    return unit.create(self, name, where)
end